function Post(opt) {
    this.init(opt);
}
Post.prototype = {
    constructor: 'Post',
    init: function (opt) {
        this.method = 'POST';
        this.url = opt.url || '';
        this.async = true;
        this.data = opt.data || null;
        this.success = opt.success || function () {}
        this.format();
    },
    format: function () {
        var data = this.data;
        var params = [];
        for (var key in data) {
            params.push(key + '=' + data[key]);
        }
        this.postData = params.join('&');
        this.xhr();
    },
    xhr: function () {
        var that = this;
        var xhr = new XMLHttpRequest();
        xhr.open(this.method, this.url, this.async);
        xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded;charset=utf-8');
        /*    xhr.setRequestHeader("Content-Length", this.data.URL.length);
         console.log(this.data.URL.length);*/
        xhr.send(this.postData);
        xhr.onreadystatechange = function () {
            if (xhr.status === 200 && xhr.readyState === 4) {
                that.success(xhr.response);
            }
        }
    }
}
